package com.bookpavilion.chat;


import com.bookpavilion.chat.netty.WSServer;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.junit4.SpringRunner;
import util.IdWorker;
import util.JwtUtil;

@SpringBootApplication
@EnableFeignClients
@EnableDiscoveryClient
@EnableEurekaClient
public class ChatApplication implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(ChatApplication.class);
    }
    @Bean
    public SpringUtil getSpingUtil() {
        return new SpringUtil();
    }
    @Bean
    public JwtUtil jwtUtil(){
        return new JwtUtil();
    }

    @Override
    public void run(String... args) throws Exception {
        WSServer.getInstance().start();
    }

    @Bean
    public IdWorker idWorker(){
        return new IdWorker();
    }
    @Bean
    public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory){
        return new RabbitAdmin(connectionFactory);
    }
}
